<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Cadastro de Usuário</title>
    </h:head>
    
    
    <h:body>
     
        <p:panel header="Cadastro de Usuário">
        <h:form id="cadastro">
    <h:messages />
    
        <h:inputHidden value="#{usuarioBean.usuario.id}" />
        <h:inputHidden value="#{usuarioBean.destinoSalvar}" />
    <h:panelGrid columns="2">  
    <h:outputLabel value="Nome*:" for="nome" />
    <h:inputText  id="nome" label="nome" value="#{usuarioBean.usuario.nome}" size="30"
                  maxlength="30" required="true" requiredMessage="Nome Obrigatório">
        <f:validateLength minimum="10" maximum="30"/>
    </h:inputText>
    
    <h:outputLabel value="CPF*:" for="cpf" />
    <h:inputText  id="cpf" label="cpf" value="#{usuarioBean.usuario.cpf}" size="11"
                  maxlength="11" required="true" requiredMessage="CPF Obrigatório">
    <f:validateLength minimum="10" maximum="30"/>
    </h:inputText>
    
    <h:outputLabel value="Email*:" for="email" />
    <h:inputText  id="email" label="email" value="#{usuarioBean.usuario.email}" size="30"
                  maxlength="100" required="true" requiredMessage="Email Inválido">;
        <f:validateRegex pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+" />
    </h:inputText>
    
    
    
    <h:outputLabel value="Apelido*:" for="apelido" />
    <h:inputText  id="apelido" label="apelido" value="#{usuarioBean.usuario.apelido}"
                  size="11"
                  maxlength="11" required="true" requiredMessage="Apelido : Use no mínimo seis caracteres e no máximo 11">
       <!-- <f:validateRegex pattern="[a-z][0-9]|[.][_]{6,11}" /> -->
        <f:validateLength minimum="6" maximum="11"/>
    </h:inputText>
    
    
        
    <h:outputLabel value="Senha:*" for="senha" />
    <h:inputSecret  id="senha" label="senha" value="#{usuarioBean.usuario.senha}" size="10"
                    maxlength="10" required="true" redisplay="true" requiredMessage="Senha Obrigatória"/>
    
    <h:outputLabel value="Repetir Senha:*" for="rsenha" />
    <h:inputSecret  id="rsenha" label="rsenha" value="#{usuarioBean.confirmarSenha}" size="10"
                    maxlength="10" required="true" redisplay="true" requiredMessage="Repita a senha"/>
    
    
    <h:commandButton action="#{usuarioBean.salvar}" value="Salvar" />
    
    </h:panelGrid>   
    
    </h:form>
        </p:panel>
        
    </h:body>
</html>
